package Application.FirstApplication.xmlPrase
{
	import Application.FirstApplication.def.Manager;
	
	public class MapSrcXML
	{
		private var m_data : Object;
		
		public function MapSrcXML()
		{
		}
		
		public function prase() : void
		{
			m_data = new Object;
			
			var orgXML : XML = Manager.Source.getXML("homeMapSrcXML");
			
			var objList : Object = new Object;
			
			for each(var element:XML in orgXML.elements("box").elements())
			{
				var objInfo : Object = new Object;
				objInfo["name"] = element.@name.toString();
				objInfo["code"] = element.@code.toString();
				objInfo["offsetX"] = element.@offsetX.toString();
				objInfo["offsetY"] = element.@offsetY.toString();
				objInfo["area"] = element.@area.toString();
				objInfo["numX"] = element.@numX.toString();
				objInfo["numZ"] = element.@numZ.toString();
				objInfo["id"] = element.@id.toString();
				objInfo["url"] = "assets/mapEdit/build/" + objInfo["name"]+".png";
				
				objList[objInfo["id"]]=objInfo;
			}
			
			var floorList : Object = new Object;
			
			for each(element in orgXML.elements("floor").elements())
			{
				var floorInfo : Object = new Object;
				floorInfo["name"] = element.@name.toString();
				floorInfo["code"] = element.@code.toString();
				floorInfo["offsetX"] = element.@offsetX.toString();
				floorInfo["offsetY"] = element.@offsetY.toString();
				floorInfo["area"] = element.@area.toString();
				floorInfo["numX"] = element.@numX.toString();
				floorInfo["numZ"] = element.@numZ.toString();
				floorInfo["id"] = element.@id.toString();
				floorInfo["url"] = "assets/mapEdit/map/" + floorInfo["name"]+".png";
				
				floorList[floorInfo["code"]]=floorInfo;
			}
			
			m_data["object"] = objList;
			m_data["floor"] = floorList;
		}
		
		public function get Data():Object
		{
			return  m_data;
		}
		
		public function  ArrayList(type:String) : Array
		{
			var list : Array = [];
			
			for each(var info : Object in m_data[type])
			{
				list.push(info);
			}
			
			list.sortOn("id",Array.NUMERIC);
			
			return list;
		}
	}
}